summaryrefslogtreecommitdiff
path: root/src/tests/binary.cpp
blob: 717c171a3c1dd365e016397b9fbacb8efad57781 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "genetic/phenotypebinary.h"
#include "genetic/operatorbasic.h"

#include <bu/sio.h>
#include <bu/random.h>
#include <bu/randomcmwc.h>
#include <time.h>

using namespace Bu;

int main( int argc, char *argv[] )
{
	Bu::Random::setGenerator<Bu::RandomCmwc>();
	Bu::Random::seed( time( NULL ) );

	Genetic::OperatorBasic op( new Genetic::PhenotypeBinary( 45 ), 0.1 );
	Genetic::Phenotype *pPb1 = op.random();
	Genetic::Phenotype *pPb2 = op.random();
	Genetic::Phenotype *pPb3;

	sio << pPb1->toString() << sio.nl;
	sio << pPb2->toString() << sio.nl;

	Genetic::PhenotypeList lParents;
	lParents.append( pPb1 );
	lParents.append( pPb2 );
	pPb3 = op.mate( lParents );

	sio << pPb3->toString() << sio.nl;

	delete pPb1;
	delete pPb2;
	delete pPb3;

	return 0;
}